package main

import (
	"fmt"
)

type phone interface {
	call(number string)
	sendMessage(number string, content string)
}

type oppo struct {
	name string
}

func (myOppo oppo) call(number string) {
	// fmt.Println(myOppo.name, number)
	fmt.Println("myPhone ", myOppo.name, "is calling", number)
}

func (myOppo oppo) sendMessage(number string, content string) {
	// fmt.Println(myOppo.name,number,content)
	fmt.Println("myPhone ", myOppo.name, "is sending message to", number, "say:", content)
}

type Tree struct {
	value       int
	left, right *Tree
}

//type Person struct {
//	Age  int
//	Name string
//}
//
//// 结构体内嵌匿名成员
//type Student struct {
//	Person
//}

func main() {
	myOppoPhone := oppo{"find X3"}
	myOppoPhone.call("18654163700")
	myOppoPhone.sendMessage("18654163700", ",I am learning golang")

	//结构体中可以内嵌结构体
	//如果嵌入的结构体是本身，那么只能用指针。请看以下例子。
	/*
		tree := Tree{
			value: 1,
			left: &Tree{
				value: 1,
				left:  nil,
				right: nil,
			},
			right: &Tree{
				value: 2,
				left:  nil,
				right: nil,
			},
		}
		fmt.Printf(">>> %#v\n", tree)
	*/

	//结构体是可以比较的
	/*
		tree1 := Tree{
			value: 2,
		}

		tree2 := Tree{
			value: 2,
		}
		fmt.Printf(">>> %#v\n", tree1 == tree2)
	*/

	//结构体内嵌匿名成员
	per := Person{Age: 18,
		Name: "Tom",
	}
	stu := Student{Person: per}
	fmt.Println("stu.Age: ", stu.Age)
	fmt.Println("stu.Name: ", stu.Name)

}
